<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Getting Started with Berkeley DB</title>
    <link rel="stylesheet" href="gettingStarted.css" type="text/css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" />
    <link rel="start" href="index.html" title="Getting Started with Berkeley DB" />
    <link rel="next" href="preface.html" title="Preface" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">Getting Started with Berkeley DB</th>
        </tr>
        <tr>
          <td width="20%" align="left"> </td>
          <th width="60%" align="center"> </th>
          <td width="20%" align="right"> <a accesskey="n" href="preface.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="book" lang="en" xml:lang="en">
      <div class="titlepage">
        <div>
          <div>
            <h1 class="title"><a id="id1477248"></a>Getting Started with Berkeley DB</h1>
          </div>
          <div>
            <div class="legalnotice">
              <a id="id1477429"></a>
              <p class="legalnotice-title">
                <b>Legal Notice</b>
              </p>
              <p>
        This documentation is distributed under an open source license.
        You may review the terms of this license at:
        <a class="ulink" href="http://www.oracle.com/technology/software/products/berkeley-db/htdocs/oslicense.html" target="_top">http://www.oracle.com/technology/software/products/berkeley-db/htdocs/oslicense.html</a>
        
        
    </p>
              <p>
            Oracle, Berkeley DB,
            
            
            and
            Sleepycat are trademarks or registered trademarks of
            Oracle. All rights to these marks are reserved.
            No third-party use is permitted without the
            express prior written consent of Oracle.
    </p>
              <p>
        <span class="trademark">Java</span>™ and all Java-based marks are a trademark
        or registered trademark of Sun Microsystems,
        Inc, in the United States and other countries.
    </p>
              <p>
        To obtain a copy of this document's original source code, please
        submit a request to the Oracle Technology Network forum at:
        <a class="ulink" href="http://forums.oracle.com/forums/forum.jspa?forumID=271" target="_top">http://forums.oracle.com/forums/forum.jspa?forumID=271</a>
        
        
    </p>
            </div>
          </div>
          <div>
            <p class="pubdate">4/12/2010</p>
          </div>
        </div>
        <hr />
      </div>
      <div class="toc">
        <p>
          <b>Table of Contents</b>
        </p>
        <dl>
          <dt>
            <span class="preface">
              <a href="preface.html">Preface</a>
            </span>
          </dt>
          <dd>
            <dl>
              <dt>
                <span class="sect1">
                  <a href="preface.html#conventions">Conventions Used in this Book</a>
                </span>
              </dt>
              <dd>
                <dl>
                  <dt>
                    <span class="sect2">
                      <a href="preface.html#moreinfo">For More Information</a>
                    </span>
                  </dt>
                </dl>
              </dd>
            </dl>
          </dd>
          <dt>
            <span class="chapter">
              <a href="introduction.html">1. Introduction to Berkeley DB </a>
            </span>
          </dt>
          <dd>
            <dl>
              <dt>
                <span class="sect1">
                  <a href="introduction.html#aboutthismanual">About This Manual</a>
                </span>
              </dt>
              <dt>
                <span class="sect1">
                  <a href="javadplconcepts.html">Berkeley DB Concepts</a>
                </span>
              </dt>
              <dd>
                <dl>
                  <dt>
                    <span class="sect2">
                      <a href="javadplconcepts.html#dplenvconcepts">Environments</a>
                    </span>
                  </dt>
                  <dt>
                    <span class="sect2">
                      <a href="javadplconcepts.html#key-data">Key-Data Pairs</a>
                    </span>
                  </dt>
                  <dt>
                    <span class="sect2">
                      <a href="javadplconcepts.html#storing-intro">Storing Data</a>
                    </span>
                  </dt>
                  <dt>
                    <span class="sect2">
                      <a href="javadplconcepts.html#duplicatesintro">Duplicate Data</a>
                    </span>
                  </dt>
                  <dt>
                    <span class="sect2">
                      <a href="javadplconcepts.html#replacedeleteIntro">Replacing and Deleting Entries</a>
                    </span>
                  </dt>
                  <dt>
                    <span class="sect2">
                      <a href="javadplconcepts.html#secondary">Secondary Keys</a>
                    </span>
                  </dt>
                  <dt>
                    <span class="sect2">
                      <a href="javadplconcepts.html#whichapi">Which API Should You Use?</a>
                    </span>
                  </dt>
                </dl>
              </dd>
              <dt>
                <span class="sect1">
                  <a href="accessmethods.html">Access Methods</a>
                </span>
              </dt>
              <dd>
                <dl>
                  <dt>
                    <span class="sect2">
                      <a href="accessmethods.html#selectAM">Selecting Access Methods</a>
                    </span>
                  </dt>
                  <dt>
                    <span class="sect2">
                      <a href="accessmethods.html#BTreeVSHash">Choosing between BTree and Hash</a>
                    </span>
                  </dt>
                  <dt>
                    <span class="sect2">
                      <a href="accessmethods.html#QueueVSRecno">Choosing between Queue and Recno</a>
                    </span>
                  </dt>
                </dl>
              </dd>
              <dt>
                <span class="sect1">
                  <a href="databaseLimits.html">Database Limits and Portability</a>
                </span>
              </dt>
              <dt>
                <span class="sect1">
                  <a href="coreExceptions.html">Exception Handling</a>
                </span>
              </dt>
              <dt>
                <span class="sect1">
                  <a href="returns.html">Error Returns</a>
                </span>
              </dt>
              <dt>
                <span class="sect1">
                  <a href="gettingit.html">Getting and Using DB </a>
                </span>
              </dt>
            </dl>
          </dd>
          <dt>
            <span class="chapter">
              <a href="Env.html">2. Database Environments</a>
            </span>
          </dt>
          <dd>
            <dl>
              <dt>
                <span class="sect1">
                  <a href="Env.html#EnvOpen">Opening Database Environments</a>
                </span>
              </dt>
              <dt>
                <span class="sect1">
                  <a href="EnvClose.html">Closing Database Environments</a>
                </span>
              </dt>
              <dt>
                <span class="sect1">
                  <a href="EnvProps.html">Environment Properties</a>
                </span>
              </dt>
              <dd>
                <dl>
                  <dt>
                    <span class="sect2">
                      <a href="EnvProps.html#envconfig">The EnvironmentConfig Class</a>
                    </span>
                  </dt>
                  <dt>
                    <span class="sect2">
                      <a href="EnvProps.html#envhandleconfig">EnvironmentMutableConfig</a>
                    </span>
                  </dt>
                </dl>
              </dd>
            </dl>
          </dd>
          <dt>
            <span class="part">
              <a href="dpl.html">I. Programming with the Direct Persistence Layer</a>
            </span>
          </dt>
          <dd>
            <dl>
              <dt>
                <span class="chapter">
                  <a href="persist_first.html">3. Direct Persistence Layer First Steps</a>
                </span>
              </dt>
              <dd>
                <dl>
                  <dt>
                    <span class="sect1">
                      <a href="persist_first.html#entitystore">Entity Stores</a>
                    </span>
                  </dt>
                  <dd>
                    <dl>
                      <dt>
                        <span class="sect2">
                          <a href="persist_first.html#persist-open">Opening and Closing Environments and Stores</a>
                        </span>
                      </dt>
                    </dl>
                  </dd>
                  <dt>
                    <span class="sect1">
                      <a href="persistobject.html">Persistent Objects</a>
                    </span>
                  </dt>
                  <dt>
                    <span class="sect1">
                      <a href="saveret.html">Saving a Retrieving Data</a>
                    </span>
                  </dt>
                </dl>
              </dd>
              <dt>
                <span class="chapter">
                  <a href="persist_index.html">4. Working with Indices</a>
                </span>
              </dt>
              <dd>
                <dl>
                  <dt>
                    <span class="sect1">
                      <a href="persist_index.html#dplindexaccess">Accessing Indexes</a>
                    </span>
                  </dt>
                  <dd>
                    <dl>
                      <dt>
                        <span class="sect2">
                          <a href="persist_index.html#primaryindexaccess">Accessing Primary Indices</a>
                        </span>
                      </dt>
                      <dt>
                        <span class="sect2">
                          <a href="persist_index.html#secondaryindexaccess">Accessing Secondary Indices</a>
                        </span>
                      </dt>
                    </dl>
                  </dd>
                  <dt>
                    <span class="sect1">
                      <a href="dplindexcreate.html">Creating Indexes</a>
                    </span>
                  </dt>
                  <dd>
                    <dl>
                      <dt>
                        <span class="sect2">
                          <a href="dplindexcreate.html#dplprimaryidxdecl">Declaring a Primary Indexes</a>
                        </span>
                      </dt>
                      <dt>
                        <span class="sect2">
                          <a href="dplindexcreate.html#dplsecondaryidxdecl">Declaring Secondary Indexes</a>
                        </span>
                      </dt>
                      <dt>
                        <span class="sect2">
                          <a href="dplindexcreate.html#foreignkey">Foreign Key Constraints</a>
                        </span>
                      </dt>
                    </dl>
                  </dd>
                </dl>
              </dd>
              <dt>
                <span class="chapter">
                  <a href="persist_access.html">5. Saving and Retrieving Objects</a>
                </span>
              </dt>
              <dd>
                <dl>
                  <dt>
                    <span class="sect1">
                      <a href="persist_access.html#simpleentity">A Simple Entity Class</a>
                    </span>
                  </dt>
                  <dt>
                    <span class="sect1">
                      <a href="simpleda.html">SimpleDA.class</a>
                    </span>
                  </dt>
                  <dt>
                    <span class="sect1">
                      <a href="simpleput.html">Placing Objects in an Entity Store</a>
                    </span>
                  </dt>
                  <dt>
                    <span class="sect1">
                      <a href="simpleget.html">Retrieving Objects from an Entity Store</a>
                    </span>
                  </dt>
                  <dt>
                    <span class="sect1">
                      <a href="getmultiple.html">Retrieving Multiple Objects</a>
                    </span>
                  </dt>
                  <dd>
                    <dl>
                      <dt>
                        <span class="sect2">
                          <a href="getmultiple.html#dpl_cursor_initialize">Cursor Initialization</a>
                        </span>
                      </dt>
                      <dt>
                        <span class="sect2">
                          <a href="getmultiple.html#dpl_dups">Working with Duplicate Keys</a>
                        </span>
                      </dt>
                      <dt>
                        <span class="sect2">
                          <a href="getmultiple.html#dpl_cursor_range">Key Ranges</a>
                        </span>
                      </dt>
                    </dl>
                  </dd>
                  <dt>
                    <span class="sect1">
                      <a href="dpl_entityjoin.html">Join Cursors</a>
                    </span>
                  </dt>
                  <dt>
                    <span class="sect1">
                      <a href="dpl_delete.html">Deleting Entity Objects</a>
                    </span>
                  </dt>
                  <dt>
                    <span class="sect1">
                      <a href="dpl_replace.html">Replacing Entity Objects</a>
                    </span>
                  </dt>
                </dl>
              </dd>
              <dt>
                <span class="chapter">
                  <a href="dpl_example.html">6. A DPL Example</a>
                </span>
              </dt>
              <dd>
                <dl>
                  <dt>
                    <span class="sect1">
                      <a href="dpl_example.html#vendorclass">Vendor.java</a>
                    </span>
                  </dt>
                  <dt>
                    <span class="sect1">
                      <a href="inventoryclass.html">Inventory.java</a>
                    </span>
                  </dt>
                  <dt>
                    <span class="sect1">
                      <a href="mydbenv-persist.html">MyDbEnv</a>
                    </span>
                  </dt>
                  <dt>
                    <span class="sect1">
                      <a href="dataaccessorclass.html">DataAccessor.java</a>
                    </span>
                  </dt>
                  <dt>
                    <span class="sect1">
                      <a href="dpl_exampledatabaseput.html">ExampleDatabasePut.java</a>
                    </span>
                  </dt>
                  <dt>
                    <span class="sect1">
                      <a href="dpl_exampleinventoryread.html">ExampleInventoryRead.java</a>
                    </span>
                  </dt>
                </dl>
              </dd>
            </dl>
          </dd>
          <dt>
            <span class="part">
              <a href="baseapi.html">II. Programming with the Base API</a>
            </span>
          </dt>
          <dd>
            <dl>
              <dt>
                <span class="chapter">
                  <a href="DB.html">7. Databases</a>
                </span>
              </dt>
              <dd>
                <dl>
                  <dt>
                    <span class="sect1">
                      <a href="DB.html#DBOpen">Opening Databases</a>
                    </span>
                  </dt>
                  <dt>
                    <span class="sect1">
                      <a href="coredbclose.html">Closing Databases</a>
                    </span>
                  </dt>
                  <dt>
                    <span class="sect1">
                      <a href="DBConfig.html">Database Properties</a>
                    </span>
                  </dt>
                  <dt>
                    <span class="sect1">
                      <a href="DBAdmin.html">Administrative Methods</a>
                    </span>
                  </dt>
                  <dt>
                    <span class="sect1">
                      <a href="dbErrorReporting.html">Error Reporting Functions</a>
                    </span>
                  </dt>
                  <dt>
                    <span class="sect1">
                      <a href="CoreEnvUsage.html">Managing Databases in Environments</a>
                    </span>
                  </dt>
                  <dt>
                    <span class="sect1">
                      <a href="CoreJavaUsage.html">Database Example</a>
                    </span>
                  </dt>
                </dl>
              </dd>
              <dt>
                <span class="chapter">
                  <a href="DBEntry.html">8. Database Records</a>
                </span>
              </dt>
              <dd>
                <dl>
                  <dt>
                    <span class="sect1">
                      <a href="DBEntry.html#usingDbEntry">Using Database Records</a>
                    </span>
                  </dt>
                  <dt>
                    <span class="sect1">
                      <a href="usingDbt.html">Reading and Writing Database Records</a>
                    </span>
                  </dt>
                  <dd>
                    <dl>
                      <dt>
                        <span class="sect2">
                          <a href="usingDbt.html#databaseWrite">Writing Records to the Database</a>
                        </span>
                      </dt>
                      <dt>
                        <span class="sect2">
                          <a href="usingDbt.html#databaseRead">Getting Records from the Database</a>
                        </span>
                      </dt>
                      <dt>
                        <span class="sect2">
                          <a href="usingDbt.html#recordDelete">Deleting Records</a>
                        </span>
                      </dt>
                      <dt>
                        <span class="sect2">
                          <a href="usingDbt.html#datapersist">Data Persistence</a>
                        </span>
                      </dt>
                    </dl>
                  </dd>
                  <dt>
                    <span class="sect1">
                      <a href="bindAPI.html">Using the BIND APIs</a>
                    </span>
                  </dt>
                  <dd>
                    <dl>
                      <dt>
                        <span class="sect2">
                          <a href="bindAPI.html#bindPrimitive">Numerical and String Objects</a>
                        </span>
                      </dt>
                      <dt>
                        <span class="sect2">
                          <a href="bindAPI.html#object2dbt">Serializable Complex Objects</a>
                        </span>
                      </dt>
                      <dt>
                        <span class="sect2">
                          <a href="bindAPI.html#customTuple">Custom Tuple Bindings</a>
                        </span>
                      </dt>
                    </dl>
                  </dd>
                  <dt>
                    <span class="sect1">
                      <a href="dbtJavaUsage.html">Database Usage Example</a>
                    </span>
                  </dt>
                </dl>
              </dd>
              <dt>
                <span class="chapter">
                  <a href="Cursors.html">9. Using Cursors</a>
                </span>
              </dt>
              <dd>
                <dl>
                  <dt>
                    <span class="sect1">
                      <a href="Cursors.html#openCursor">Opening and Closing Cursors</a>
                    </span>
                  </dt>
                  <dt>
                    <span class="sect1">
                      <a href="Positioning.html">Getting Records Using the Cursor</a>
                    </span>
                  </dt>
                  <dd>
                    <dl>
                      <dt>
                        <span class="sect2">
                          <a href="Positioning.html#cursorsearch">Searching for Records</a>
                        </span>
                      </dt>
                      <dt>
                        <span class="sect2">
                          <a href="Positioning.html#getdups">Working with Duplicate Records</a>
                        </span>
                      </dt>
                    </dl>
                  </dd>
                  <dt>
                    <span class="sect1">
                      <a href="PutEntryWCursor.html">Putting Records Using Cursors</a>
                    </span>
                  </dt>
                  <dt>
                    <span class="sect1">
                      <a href="DeleteEntryWCursor.html">Deleting Records Using Cursors</a>
                    </span>
                  </dt>
                  <dt>
                    <span class="sect1">
                      <a href="ReplacingEntryWCursor.html">Replacing Records Using Cursors</a>
                    </span>
                  </dt>
                  <dt>
                    <span class="sect1">
                      <a href="cursorJavaUsage.html">Cursor Example</a>
                    </span>
                  </dt>
                </dl>
              </dd>
              <dt>
                <span class="chapter">
                  <a href="indexes.html">10. Secondary Databases</a>
                </span>
              </dt>
              <dd>
                <dl>
                  <dt>
                    <span class="sect1">
                      <a href="indexes.html#DbAssociate">Opening and Closing Secondary Databases</a>
                    </span>
                  </dt>
                  <dt>
                    <span class="sect1">
                      <a href="keyCreator.html">Implementing Key 
        <span>Creators</span>
        
        </a>
                    </span>
                  </dt>
                  <dd>
                    <dl>
                      <dt>
                        <span class="sect2">
                          <a href="keyCreator.html#multikeys">Working with Multiple Keys</a>
                        </span>
                      </dt>
                    </dl>
                  </dd>
                  <dt>
                    <span class="sect1">
                      <a href="secondaryProps.html">Secondary Database Properties</a>
                    </span>
                  </dt>
                  <dt>
                    <span class="sect1">
                      <a href="readSecondary.html">Reading Secondary Databases</a>
                    </span>
                  </dt>
                  <dt>
                    <span class="sect1">
                      <a href="secondaryDelete.html">Deleting Secondary Database Records</a>
                    </span>
                  </dt>
                  <dt>
                    <span class="sect1">
                      <a href="secondaryCursor.html">
        <span>Using Secondary Cursors</span>
        
    </a>
                    </span>
                  </dt>
                  <dt>
                    <span class="sect1">
                      <a href="joins.html">Database Joins</a>
                    </span>
                  </dt>
                  <dd>
                    <dl>
                      <dt>
                        <span class="sect2">
                          <a href="joins.html#joinUsage">Using Join Cursors</a>
                        </span>
                      </dt>
                      <dt>
                        <span class="sect2">
                          <a href="joins.html#joinconfig">JoinCursor Properties</a>
                        </span>
                      </dt>
                    </dl>
                  </dd>
                  <dt>
                    <span class="sect1">
                      <a href="javaindexusage.html">Secondary Database Example</a>
                    </span>
                  </dt>
                  <dd>
                    <dl>
                      <dt>
                        <span class="sect2">
                          <a href="javaindexusage.html#secondaryMyDbs">Opening Secondary Databases with MyDbs</a>
                        </span>
                      </dt>
                      <dt>
                        <span class="sect2">
                          <a href="javaindexusage.html#exampleReadJavaSecondaries">Using Secondary Databases with ExampleDatabaseRead</a>
                        </span>
                      </dt>
                    </dl>
                  </dd>
                </dl>
              </dd>
              <dt>
                <span class="chapter">
                  <a href="dbconfig.html">11. Database Configuration</a>
                </span>
              </dt>
              <dd>
                <dl>
                  <dt>
                    <span class="sect1">
                      <a href="dbconfig.html#pagesize">Setting the Page Size</a>
                    </span>
                  </dt>
                  <dd>
                    <dl>
                      <dt>
                        <span class="sect2">
                          <a href="dbconfig.html#overflowpages">Overflow Pages</a>
                        </span>
                      </dt>
                      <dt>
                        <span class="sect2">
                          <a href="dbconfig.html#Locking">Locking</a>
                        </span>
                      </dt>
                      <dt>
                        <span class="sect2">
                          <a href="dbconfig.html#IOEfficiency">IO Efficiency</a>
                        </span>
                      </dt>
                      <dt>
                        <span class="sect2">
                          <a href="dbconfig.html#pagesizeAdvice">Page Sizing Advice</a>
                        </span>
                      </dt>
                    </dl>
                  </dd>
                  <dt>
                    <span class="sect1">
                      <a href="cachesize.html">Selecting the Cache Size</a>
                    </span>
                  </dt>
                  <dt>
                    <span class="sect1">
                      <a href="btree.html">BTree Configuration</a>
                    </span>
                  </dt>
                  <dd>
                    <dl>
                      <dt>
                        <span class="sect2">
                          <a href="btree.html#duplicateRecords">Allowing Duplicate Records</a>
                        </span>
                      </dt>
                      <dt>
                        <span class="sect2">
                          <a href="btree.html#comparators">Setting Comparison Functions</a>
                        </span>
                      </dt>
                    </dl>
                  </dd>
                </dl>
              </dd>
            </dl>
          </dd>
        </dl>
      </div>
      <div class="list-of-examples">
        <p>
          <b>List of Examples</b>
        </p>
        <dl>
          <dt>7.1. <a href="CoreJavaUsage.html#MyDb">MyDbs Class</a></dt>
          <dt>8.1. <a href="dbtJavaUsage.html#inventoryjava">Inventory.java</a></dt>
          <dt>8.2. <a href="dbtJavaUsage.html#vendorjava">Vendor.java</a></dt>
          <dt>8.3. <a href="dbtJavaUsage.html#InventoryJavaBinding">InventoryBinding.java</a></dt>
          <dt>8.4. <a href="dbtJavaUsage.html#dbsStoredClass">Stored Class Catalog Management with MyDbs</a></dt>
          <dt>8.5. <a href="dbtJavaUsage.html#EDL">ExampleDatabaseLoad.java</a></dt>
          <dt>9.1. <a href="cursorJavaUsage.html#EDR">ExampleDatabaseRead.java</a></dt>
          <dt>10.1. <a href="javaindexusage.html#ItemNameKeyCreator-Java">ItemNameKeyCreator.java</a></dt>
          <dt>10.2. <a href="javaindexusage.html#mydbsSecondary">SecondaryDatabase Management with MyDbs</a></dt>
          <dt>10.3. <a href="javaindexusage.html#secondaryWithEDR">SecondaryDatabase usage with ExampleDatabaseRead</a></dt>
        </dl>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"> </td>
          <td width="20%" align="center"> </td>
          <td width="40%" align="right"> <a accesskey="n" href="preface.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top"> </td>
          <td width="20%" align="center"> </td>
          <td width="40%" align="right" valign="top"> Preface</td>
        </tr>
      </table>
    </div>
  </body>
</html>
